package api;

class PrintUtil{
    //泛型定义对静态方法无法生效，所以要在返回值左边加上泛型
    public static <T> void printArray(T[] array){
        for (T element : array){
            System.out.print(element + " ");
        }
    }
}
public class GenericDemo3 {
    public static void main(String[] args) {
        Integer[] i = {1,2,3};
        PrintUtil.printArray(i);//自动进行类型推算
        System.out.println();
        String[] s = {"aa","bb"};
        PrintUtil.printArray(s);
    }
}
